﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZhangZhao.Web.H_UserGatherThirdPhoto
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int Id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(Id);
				}
			}
		}
			
	private void ShowInfo(int Id)
	{
		ZhangZhao.BLL.H_UserGatherThirdPhoto bll=new ZhangZhao.BLL.H_UserGatherThirdPhoto();
		ZhangZhao.Model.H_UserGatherThirdPhoto model=bll.GetModel(Id);
		this.lblId.Text=model.Id.ToString();
		this.txtUserName.Text=model.UserName;
		this.txtThirdUserName.Text=model.ThirdUserName;
		this.txtThirdPhotoThumb.Text=model.ThirdPhotoThumb;
		this.txtThirdPhotoLarge.Text=model.ThirdPhotoLarge;
		this.chkIsLike.Checked=model.IsLike;
		this.txtCreatedTime.Text=model.CreatedTime.ToString();
		this.txtViewCount.Text=model.ViewCount.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtUserName.Text.Trim().Length==0)
			{
				strErr+="UserName不能为空！\\n";	
			}
			if(this.txtThirdUserName.Text.Trim().Length==0)
			{
				strErr+="ThirdUserName不能为空！\\n";	
			}
			if(this.txtThirdPhotoThumb.Text.Trim().Length==0)
			{
				strErr+="ThirdPhotoThumb不能为空！\\n";	
			}
			if(this.txtThirdPhotoLarge.Text.Trim().Length==0)
			{
				strErr+="ThirdPhotoLarge不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreatedTime.Text))
			{
				strErr+="CreatedTime格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtViewCount.Text))
			{
				strErr+="ViewCount格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int Id=int.Parse(this.lblId.Text);
			string UserName=this.txtUserName.Text;
			string ThirdUserName=this.txtThirdUserName.Text;
			string ThirdPhotoThumb=this.txtThirdPhotoThumb.Text;
			string ThirdPhotoLarge=this.txtThirdPhotoLarge.Text;
			bool IsLike=this.chkIsLike.Checked;
			DateTime CreatedTime=DateTime.Parse(this.txtCreatedTime.Text);
			int ViewCount=int.Parse(this.txtViewCount.Text);


			ZhangZhao.Model.H_UserGatherThirdPhoto model=new ZhangZhao.Model.H_UserGatherThirdPhoto();
			model.Id=Id;
			model.UserName=UserName;
			model.ThirdUserName=ThirdUserName;
			model.ThirdPhotoThumb=ThirdPhotoThumb;
			model.ThirdPhotoLarge=ThirdPhotoLarge;
			model.IsLike=IsLike;
			model.CreatedTime=CreatedTime;
			model.ViewCount=ViewCount;

			ZhangZhao.BLL.H_UserGatherThirdPhoto bll=new ZhangZhao.BLL.H_UserGatherThirdPhoto();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
